package gonz.pages.swim;

import gonz.common.Waiter;
import gonz.data.swim.TwoPiecesSwim;
import gonz.pages.AbstractPage;
import org.apache.log4j.Logger;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

public class SwimIndexPage extends AbstractPage {
    public static final String BIKINIS_CATEGORY_ID = "swimwearbikinis";
    public static final String TANKINIS_CATEGORY_ID = "swimweartankinis";
    public static final String ONE_PIECES_ID = "swimwearone-piece";
    public static final String COVER_UP_ID = "swimwearcover-ups";
    public static final String FIRST_SWIM_XPATH = "//ul[@id='collection']/li/ul/li/a";
    //ul[@id='collection']/li/ul/li/a/span/img
    public static final Logger log = Logger.getLogger(SwimIndexPage.class);
    public static final String FOOTER_ID = "footer";

    public SwimIndexPage(WebDriver webDriver) {
        super(webDriver);
        Waiter.waitElement(webDriver, By.id(FOOTER_ID));
    }

    public SwimIndexPage(WebDriver webDriver, String link) {
        super(webDriver);
        webDriver.get(link);
        Waiter.waitElement(webDriver, By.id(FOOTER_ID));
    }

    public void openBikinisCategory() {
        webDriver.findElement(By.id(BIKINIS_CATEGORY_ID)).click();
    }


    public TwoPiecesSwim openFirstSwim(String imgFolder) {
        Waiter.waitElement(webDriver, By.xpath(FIRST_SWIM_XPATH));
        webDriver.findElement(By.xpath(FIRST_SWIM_XPATH)).click();
        return new TwoPiecesSwim(webDriver, imgFolder);
    }

    public void openTankinisCategory() {
        webDriver.findElement(By.id(TANKINIS_CATEGORY_ID)).click();
    }

    public void openOnePiecesCategory() {
        webDriver.findElement(By.id(ONE_PIECES_ID)).click();
    }

    public void openCoverUpCategory() {
        webDriver.findElement(By.id(COVER_UP_ID)).click();
    }
}
